from pydantic import BaseModel, Field
from typing import Optional
{% set DECIMAL_TYPES = ['DECIMAL', 'NUMERIC', 'MONEY', 'NUMMULTIRANGE', 'NUMRANGE'] %}
{% set DATETIME_TYPES = ['DATETIME', 'TIMESTAMP', 'TIMESTAMPTZ'] %}
{% set DATE_TYPES = ['DATE'] %}

{% if model_types|select('in', DECIMAL_TYPES)|first %}
from decimal import Decimal
{% endif %}
{% if model_types|select('in', DATETIME_TYPES)|first %}
from datetime import datetime
{% endif %}
{% if model_types|select('in', DATE_TYPES)|first %}
from datetime import date
{% endif %}


class {{ class_name }}Query(BaseModel):
    page: int = Field(1, ge=1, description="页码", alias="current")
    size: int = Field(10, ge=1, le=100, description="每页数量")

{% for col in models %}
{% if col.pd_type == 'str' %}
    {{ col.name }}: Optional[str] = Field(None, description="按 {{ col.comment or col.name }} 字符串模糊匹配")
{% else %}
    {{ col.name }}: Optional[{{ col.pd_type }}] = Field(None, description="按 {{ col.comment or col.name }} 过滤")
{% endif %}
{% endfor %}

{% for col in models %}
{% if col.pd_type in ['datetime', 'date'] %}
    {{ col.name }}_from: Optional[{{ col.pd_type }}] = Field(None, description="{{ col.comment or col.name }} 起始")
    {{ col.name }}_to: Optional[{{ col.pd_type }}] = Field(None, description="{{ col.comment or col.name }} 结束")
{% endif %}
{% endfor %}